package pattern.command;


public class Main {

    public static void main(String[] args) {

        //创建接受者，空调就是接受者
        ConditionReceiver receiver = new ConditionReceiver();

        //创建命令对象，设置命令的接受者
        Command onCommand = new OnCommand(receiver);
        Command offCommand = new OffCommand(receiver);
        Command coolCommand = new CoolCommand(receiver);
        Command warmCommand = new WarmCommand(receiver);

        //创建请求者，把命令对象设置进去，app就是请求发起者
        AppInvoker appInvoker = new AppInvoker();
        appInvoker.setOnCommand(onCommand);
        appInvoker.setOffCommand(offCommand);
        appInvoker.setCoolCommand(coolCommand);
        appInvoker.setWarmCommand(warmCommand);

        appInvoker.on();
        System.out.println();

        appInvoker.cool();
        System.out.println();

        appInvoker.warm();
        System.out.println();

        appInvoker.off();



    }
}
